package com.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.DepDAO;
import com.pojo.Dep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DepService extends ServiceImpl<DepDAO, Dep> {


    @Autowired
    private  DepDAO depDAO;


    /**
     *
     * @param page   第几页
     * @param limit  页大小
     * @param depId
     * @param depName
     * @return
     */
    public IPage searchDep(int page, int limit ,Integer depId, String depName)
    {
        //封装分页参数
        Page pageParam = new Page(page,limit);

        //封装查询参数
        QueryWrapper q = new QueryWrapper();
        if (depId!=null)
        {
            q.eq("depId",depId);
        }
        if (depName!=null && depName.length()>0)
        {
            q.like("depName", "%"+depName+"%");
        }

        //查
        IPage result =  depDAO.selectPage(pageParam, q);
        //public IPage searchEmpPage(Page p, @Param("m") Map map);

        return result;

    }



}
